<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        section{
            border-radius: 10px;
            border:1px solid red;
            width: 500px;
            height: 500px;
            position: absolute;
            left:0;
            right:0;
            top: 0; 
            bottom: 0;
            margin:auto
        }
        #div1,
        #div2 {
            width: 200px;
            height: 150px;
            padding: 20px;
            margin: 20px auto;
            border: 1px solid white
        }

        #div1 {
            border: 5px solid red;
            background-color: yellow;
            box-sizing: border-box;
        }

        #div2 {
            background-color: blue;
            box-sizing: content-box;
            border: 2px solid red;
        }

        #div3 {
            background-color: white;

        }

        #div4 {
            background-color: yellow;
            width: 200px;
            height: 150px;
        }

        .shopping_cart_image {
            width: 21px;
            height: 24px;
        }

        .shopping_cart_image_empty {
            background: url(../images/small_icons.jpg) no-repeat -250px -465px/500px 500px;
            /*background的缩写形式*/
        }

        .shopping_cart_image_full {
            background-image: url(../images/small_icons.jpg);
            background-size: 500px 500px;
            background-repeat: no-repeat;
            background-position: -366px -400px;
        }
    </style>
</head>

<body>
    <section>
        IE盒模型（width=200px;heigth=150px）
        <div id="div1">
            <div id="div3">div3</div>
        </div>
        标准盒模型（width=200px;heigth=150px）
        <div id="div2">
            <div id="div4">div4</div>
        </div>
    </section>
    <div id="div5" style="width:100px;height: 100px;border-radius: 50px;border: 1px solid red;"></div>
    <div id="shopping_cart" class="shopping_cart_image shopping_cart_image_full">
        <button id="btn_empty">清空购物车</button>
    </div>
</body>

</html>
<script>
    document.getElementById("btn_empty").addEventListener("click", () => {
        var shopping_cart_class = document.getElementById("shopping_cart").classList;
        if (Array.from(shopping_cart_class).includes("shopping_cart_image_full")) {
            shopping_cart_class.remove("shopping_cart_image_full");
            shopping_cart_class.add("shopping_cart_image_empty");
            document.getElementById("btn_empty").innerHTML = "填满购物车";
        } else {
            shopping_cart_class.add("shopping_cart_image_full");
            shopping_cart_class.remove("shopping_cart_image_empty");
            document.getElementById("btn_empty").innerHTML = "清空购物车";
        }
    }, false);
</script>